*E: 0,1,2,3.
*L: *[],[0],[1],[2],[3],[01],[02],[03],[10],[12],[13],[20],[21],[23],[30],[31],[32],[012],[013],[021],[023],[031],[032],[102],[103],[120],[123],[130],[132],[201],[203],[210],[213],[230],[231],[301],[302],[310],[312],[320],[321],[0123],[0132],[0213],[0231],[0312],[0321],[1023],[1032],[1203],[1230],[1302],[1320],[2013],[2031],[2103],[2130],[2301],[2310],[3012],[3021],[3102],[3120],[3201],[3210].

*elt(E)
0
1
2
3
.
*append(L,L,L) ##-
[], [], []
[], [0], [0]
[0], [], [0]
[], [1], [1]
[1], [], [1]
[], [2], [2]
[2], [], [2]
[], [3], [3]
[3], [], [3]
[], [01], [01]
[0], [1], [01]
[01], [], [01]
[], [02], [02]
[0], [2], [02]
[02], [], [02]
[], [03], [03]
[0], [3], [03]
[03], [], [03]
[], [10], [10]
[1], [0], [10]
[10], [], [10]
[], [12], [12]
[1], [2], [12]
[12], [], [12]
[], [13], [13]
[1], [3], [13]
[13], [], [13]
[], [20], [20]
[2], [0], [20]
[20], [], [20]
[], [21], [21]
[2], [1], [21]
[21], [], [21]
[], [23], [23]
[2], [3], [23]
[23], [], [23]
[], [30], [30]
[3], [0], [30]
[30], [], [30]
[], [31], [31]
[3], [1], [31]
[31], [], [31]
[], [32], [32]
[3], [2], [32]
[32], [], [32]
[], [012], [012]
[0], [12], [012]
[01], [2], [012]
[012], [], [012]
[], [013], [013]
[0], [13], [013]
[01], [3], [013]
[013], [], [013]
[], [021], [021]
[0], [21], [021]
[02], [1], [021]
[021], [], [021]
[], [023], [023]
[0], [23], [023]
[02], [3], [023]
[023], [], [023]
[], [031], [031]
[0], [31], [031]
[03], [1], [031]
[031], [], [031]
[], [032], [032]
[0], [32], [032]
[03], [2], [032]
[032], [], [032]
[], [102], [102]
[1], [02], [102]
[10], [2], [102]
[102], [], [102]
[], [103], [103]
[1], [03], [103]
[10], [3], [103]
[103], [], [103]
[], [120], [120]
[1], [20], [120]
[12], [0], [120]
[120], [], [120]
[], [123], [123]
[1], [23], [123]
[12], [3], [123]
[123], [], [123]
[], [130], [130]
[1], [30], [130]
[13], [0], [130]
[130], [], [130]
[], [132], [132]
[1], [32], [132]
[13], [2], [132]
[132], [], [132]
[], [201], [201]
[2], [01], [201]
[20], [1], [201]
[201], [], [201]
[], [203], [203]
[2], [03], [203]
[20], [3], [203]
[203], [], [203]
[], [210], [210]
[2], [10], [210]
[21], [0], [210]
[210], [], [210]
[], [213], [213]
[2], [13], [213]
[21], [3], [213]
[213], [], [213]
[], [230], [230]
[2], [30], [230]
[23], [0], [230]
[230], [], [230]
[], [231], [231]
[2], [31], [231]
[23], [1], [231]
[231], [], [231]
[], [301], [301]
[3], [01], [301]
[30], [1], [301]
[301], [], [301]
[], [302], [302]
[3], [02], [302]
[30], [2], [302]
[302], [], [302]
[], [310], [310]
[3], [10], [310]
[31], [0], [310]
[310], [], [310]
[], [312], [312]
[3], [12], [312]
[31], [2], [312]
[312], [], [312]
[], [320], [320]
[3], [20], [320]
[32], [0], [320]
[320], [], [320]
[], [321], [321]
[3], [21], [321]
[32], [1], [321]
[321], [], [321]
[], [0123], [0123]
[0], [123], [0123]
[01], [23], [0123]
[012], [3], [0123]
[0123], [], [0123]
[], [0132], [0132]
[0], [132], [0132]
[01], [32], [0132]
[013], [2], [0132]
[0132], [], [0132]
[], [0213], [0213]
[0], [213], [0213]
[02], [13], [0213]
[021], [3], [0213]
[0213], [], [0213]
[], [0231], [0231]
[0], [231], [0231]
[02], [31], [0231]
[023], [1], [0231]
[0231], [], [0231]
[], [0312], [0312]
[0], [312], [0312]
[03], [12], [0312]
[031], [2], [0312]
[0312], [], [0312]
[], [0321], [0321]
[0], [321], [0321]
[03], [21], [0321]
[032], [1], [0321]
[0321], [], [0321]
[], [1023], [1023]
[1], [023], [1023]
[10], [23], [1023]
[102], [3], [1023]
[1023], [], [1023]
[], [1032], [1032]
[1], [032], [1032]
[10], [32], [1032]
[103], [2], [1032]
[1032], [], [1032]
[], [1203], [1203]
[1], [203], [1203]
[12], [03], [1203]
[120], [3], [1203]
[1203], [], [1203]
[], [1230], [1230]
[1], [230], [1230]
[12], [30], [1230]
[123], [0], [1230]
[1230], [], [1230]
[], [1302], [1302]
[1], [302], [1302]
[13], [02], [1302]
[130], [2], [1302]
[1302], [], [1302]
[], [1320], [1320]
[1], [320], [1320]
[13], [20], [1320]
[132], [0], [1320]
[1320], [], [1320]
[], [2013], [2013]
[2], [013], [2013]
[20], [13], [2013]
[201], [3], [2013]
[2013], [], [2013]
[], [2031], [2031]
[2], [031], [2031]
[20], [31], [2031]
[203], [1], [2031]
[2031], [], [2031]
[], [2103], [2103]
[2], [103], [2103]
[21], [03], [2103]
[210], [3], [2103]
[2103], [], [2103]
[], [2130], [2130]
[2], [130], [2130]
[21], [30], [2130]
[213], [0], [2130]
[2130], [], [2130]
[], [2301], [2301]
[2], [301], [2301]
[23], [01], [2301]
[230], [1], [2301]
[2301], [], [2301]
[], [2310], [2310]
[2], [310], [2310]
[23], [10], [2310]
[231], [0], [2310]
[2310], [], [2310]
[], [3012], [3012]
[3], [012], [3012]
[30], [12], [3012]
[301], [2], [3012]
[3012], [], [3012]
[], [3021], [3021]
[3], [021], [3021]
[30], [21], [3021]
[302], [1], [3021]
[3021], [], [3021]
[], [3102], [3102]
[3], [102], [3102]
[31], [02], [3102]
[310], [2], [3102]
[3102], [], [3102]
[], [3120], [3120]
[3], [120], [3120]
[31], [20], [3120]
[312], [0], [3120]
[3120], [], [3120]
[], [3201], [3201]
[3], [201], [3201]
[32], [01], [3201]
[320], [1], [3201]
[3201], [], [3201]
[], [3210], [3210]
[3], [210], [3210]
[32], [10], [3210]
[321], [0], [3210]
[3210], [], [3210]
.
*components(L,E,L) #--/-##
[0], 0, []
[1], 1, []
[2], 2, []
[3], 3, []
[01], 0, [1]
[02], 0, [2]
[03], 0, [3]
[10], 1, [0]
[12], 1, [2]
[13], 1, [3]
[20], 2, [0]
[21], 2, [1]
[23], 2, [3]
[30], 3, [0]
[31], 3, [1]
[32], 3, [2]
[012], 0, [12]
[013], 0, [13]
[021], 0, [21]
[023], 0, [23]
[031], 0, [31]
[032], 0, [32]
[102], 1, [02]
[103], 1, [03]
[120], 1, [20]
[123], 1, [23]
[130], 1, [30]
[132], 1, [32]
[201], 2, [01]
[203], 2, [03]
[210], 2, [10]
[213], 2, [13]
[230], 2, [30]
[231], 2, [31]
[301], 3, [01]
[302], 3, [02]
[310], 3, [10]
[312], 3, [12]
[320], 3, [20]
[321], 3, [21]
[0123], 0, [123]
[0132], 0, [132]
[0213], 0, [213]
[0231], 0, [231]
[0312], 0, [312]
[0321], 0, [321]
[1023], 1, [023]
[1032], 1, [032]
[1203], 1, [203]
[1230], 1, [230]
[1302], 1, [302]
[1320], 1, [320]
[2013], 2, [013]
[2031], 2, [031]
[2103], 2, [103]
[2130], 2, [130]
[2301], 2, [301]
[2310], 2, [310]
[3012], 3, [012]
[3021], 3, [021]
[3102], 3, [102]
[3120], 3, [120]
[3201], 3, [201]
[3210], 3, [210]
.
sort(L, L) #-
[], []
[0], [0]
[1], [1]
[2], [2]
[3], [3]
[01], [01]
[02], [02]
[03], [03]
[10], [01]
[12], [12]
[13], [13]
[20], [02]
[21], [12]
[23], [23]
[30], [03]
[31], [13]
[32], [23]
[012], [012]
[013], [013]
[021], [012]
[023], [023]
[031], [013]
[032], [023]
[102], [012]
[103], [013]
[120], [012]
[123], [123]
[130], [013]
[132], [123]
[201], [012]
[203], [023]
[210], [012]
[213], [123]
[230], [023]
[231], [123]
[301], [013]
[302], [023]
[310], [013]
[312], [123]
[320], [023]
[321], [123]
[0123], [0123]
[0132], [0123]
[0213], [0123]
[0231], [0123]
[0312], [0123]
[0321], [0123]
[1023], [0123]
[1032], [0123]
[1203], [0123]
[1230], [0123]
[1302], [0123]
[1320], [0123]
[2013], [0123]
[2031], [0123]
[2103], [0123]
[2130], [0123]
[2301], [0123]
[2310], [0123]
[3012], [0123]
[3021], [0123]
[3102], [0123]
[3120], [0123]
[3201], [0123]
[3210], [0123]
.
*partition(E,L,L,L) ##--
0, [], [], []
1, [], [], []
2, [], [], []
3, [], [], []
1, [0], [0], []
2, [0], [0], []
3, [0], [0], []
0, [1], [], [1]
2, [1], [1], []
3, [1], [1], []
0, [2], [], [2]
1, [2], [], [2]
3, [2], [2], []
0, [3], [], [3]
1, [3], [], [3]
2, [3], [], [3]
2, [01], [01], []
3, [01], [01], []
1, [02], [0], [2]
3, [02], [02], []
1, [03], [0], [3]
2, [03], [0], [3]
2, [10], [10], []
3, [10], [10], []
0, [12], [], [12]
3, [12], [12], []
0, [13], [], [13]
2, [13], [1], [3]
1, [20], [0], [2]
3, [20], [20], []
0, [21], [], [21]
3, [21], [21], []
0, [23], [], [23]
1, [23], [], [23]
1, [30], [0], [3]
2, [30], [0], [3]
0, [31], [], [31]
2, [31], [1], [3]
0, [32], [], [32]
1, [32], [], [32]
3, [012], [012], []
2, [013], [01], [3]
3, [021], [021], []
1, [023], [0], [23]
2, [031], [01], [3]
1, [032], [0], [32]
3, [102], [102], []
2, [103], [10], [3]
3, [120], [120], []
0, [123], [], [123]
2, [130], [10], [3]
0, [132], [], [132]
3, [201], [201], []
1, [203], [0], [23]
3, [210], [210], []
0, [213], [], [213]
1, [230], [0], [23]
0, [231], [], [231]
2, [301], [01], [3]
1, [302], [0], [32]
2, [310], [10], [3]
0, [312], [], [312]
1, [320], [0], [32]
0, [321], [], [321]
.
